DP G bad
DP_G bad
PyPy 15TLE
code:python
def solve(N, M, edges):
path = edges.copy()
exists = 1
for i in range(2, M + 1):
next_path = defaultdict(set)
for v1 in path:
next_pathv1.update(edgesv2) exists = i
if exists != i:
# no more pathes
break
path = next_path
return exists